<%@ page import="java.sql.*" %>
<%@ page import="java.util.List" %>
<%@ page import="com.liu.lab03.pojo.Music" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
    <title>音乐管理系统</title>
    <style type="text/css">
        table,th{
            border-spacing: 0em;
            margin-left: 1px;
            border: 1px solid #220808;
            border-collapse: collapse;
        }/*设置表格最外层边框实线*/
        th{
            color: white;
            background-color: rgba(38, 45, 59, 0.767);
        }
        td{
            border: 1px dashed;
        }/*设置单元格边框纵向虚线*/
        tr{
            vertical-align: top;
            border: 1px dashed;
        }/*设置单元格边框横向虚线*/
    </style>
</head>
<body>
   <!--输入关键词，点击提交按钮，跳转到ShowAllMusicsServlet文件-->
<form action="showAllMusics" method="post">
    按歌名查找：<input type="text" name="key"/>
    <input type="submit" value="搜索"/>
</form>
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="addMusic.jsp">添加音乐</a>
<%
   //获取session中保存的音乐信息列表
    List<Music> musicList = (List<Music>)session.getAttribute("allMusics");
    //输出查询结果
    out.println("<table width='50%' style='border-spacing: 0em;margin-left: 1px;border: 1px solid #220808;border-collapse: collapse;'>");
    out.println("<tr><th>id</th><th>歌名</th><th>演唱者</th><th>排名</th><th>分类</th><th>编辑</th></tr>");
    for (Music m : musicList) {
        out.println("<tr>");
        out.println("<td>"+m.getId()+"</td>");
        out.println("<td>"+m.getMusicname()+"</td>");
        out.println("<td>"+m.getSinger()+"</td>");
        out.println("<td>"+m.getRanking()+"</td>");
        out.println("<td>"+m.getCategory_id()+"</td>");
        out.println("<td>");
        out.println("<a href='findMusicById?id="+m.getId()+"'>修改</a>");
        out.println("<a href='deleteMusic?id="+m.getId()+"'>删除</a>");
        out.println("</td>");
        out.println("</tr>");
    }
    out.println("</table>");
%>
</body>
</html>
